'''
不能用任何python内部函数(除了len外)，自己写算法求解。在循环中只能用负数下标实现。
'''
s = [9, 7, 8, 3, 2, 1, 55, 6]
cnt = len(s)
maxNum, minNum, sum, avgNum = s[-1], s[-1], 0, 0.0
for i in range(-1, -cnt - 1, -1):
    if maxNum < s[i]:
        maxNum = s[i]
    if minNum > s[i]:
        minNum = s[i]
    sum += s[i]
avgNum = float(sum / cnt)
print(s)
print("其元素个数，最大值、最小值、和平均值分别为：%d %d %d %.4f" % (cnt, maxNum, minNum, avgNum))